<%-- 
    Document   : DisplayQues
    Created on : Mar 31, 2013, 8:01:13 PM
    Author     : Shuvo
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
         <table border="1" cellpadding="5" cellspacing="5">
        <tr>
            <th>Ques</th>
            <th>Asked By</th>
            <th>Status</th>
            <th>Replies</th>
        </tr>

       <c:forEach var="question" items="${questionList}">
            <tr>
                <td>${question.text}</td>
                <td>${question.askedBy}</td>
                <td>${question.status}</td>
                <td>${question.replies}</td>
            </tr>
        </c:forEach>
    </table>

   <%--For displaying Previous link except for the 1st page --%>
    <c:if test="${currentPage != 1}">
        <td><a href="./GetQuestions?subject=Math&status=OPEN&page=${currentPage - 1}">Previous</a></td>
    </c:if>

   <%--For displaying Page numbers.
    The when condition does not display a link for the current page--%>
    <table border="1" cellpadding="5" cellspacing="5">
        <tr>
            <c:forEach begin="1" end="${noOfPages}" var="i">
                <c:choose>
                    <c:when test="${currentPage eq i}">
                        <td>${i}</td>
                    </c:when>
                    <c:otherwise>
                         <td><a href="employee.do?page=${i}">${i}</a></td>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
        </tr>
    </table>

   <%--For displaying Next link --%>
    <c:if test="${currentPage lt noOfPages}">
        <td><a href="employee.do?page=${currentPage + 1}">Next</a></td>
    </c:if>
    </body>
</html>
